home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 98 / Skunkware 98.iso / src / fileutil / fileutils-3.16.tar.gz / fileutils-3.16.tar / fileutils-3.16 / lib / ylwrap < prev   
Text File  |  1996-10-10  |  2KB  |  63 lines

  1. #! /bin/sh
  2. # ylwrap - wrapper for lex/yacc invocations.
  3. # Written by Tom Tromey <tromey@cygnus.com>, Aug 11 1996
  4. #
  5. # This program is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation; either version 2, or (at your option)
  8. # any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write to the Free Software
  17. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18.  
  19. # Usage:
  20. #     ylwrap PROG [OUTPUT DESIRED]... -- [ARGS]...
  21. # * PROG is program to run.
  22. # * OUTPUT is file PROG generates
  23. # * DESIRED is file we actually want
  24. # * ARGS are passed to PROG
  25. # Any number of OUTPUT,DESIRED pairs may be used.
  26.  
  27. # The program to run.
  28. prog="$1"
  29. shift
  30.  
  31. pairlist=
  32. while test "$#" -ne 0; do
  33.    if test "$1" = "--"; then
  34.       break
  35.    fi
  36.    pairlist="$pairlist $1"
  37.    shift
  38. done
  39.  
  40. $prog ${1+"$@"} || exit $?
  41.  
  42. set X $pairlist
  43. shift
  44. status=0
  45. first=yes
  46. while test "$#" -ne 0; do
  47.    if test -f "$1"; then
  48.       mv "$1" "$2" || status=$?
  49.    else
  50.       # A missing file is only an error for the first file.  This is a
  51.       # blatant hack to let us support using "yacc -d".  If -d is not
  52.       # specified, we don't want an error when the header file is
  53.       # "missing".
  54.       if test $first = yes; then
  55.      status=1
  56.       fi
  57.    fi
  58.    shift
  59.    shift
  60.    first=no
  61. done
  62. exit $status
  63.